<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../own/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../own/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>

    <div class="layui-form layuimini-form" lay-filter="updateSubmit">
        <input type="hidden" name="id">
        <input type="hidden" name="typeIds" id="typeIds">
        <div class="layui-form-item">
            <label class="layui-form-label required">业主姓名</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" lay-reqtext="业主姓名不能为空"
                       placeholder="请输入业主姓名" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">业主电话</label>
            <div class="layui-input-block">
                <input type="text" name="tel" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="男" title="男" checked="">
                <input type="radio" name="sex" value="女" title="女">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">身份证号</label>
            <div class="layui-input-block">
                <input type="text" name="identity" lay-verify="required" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">房子编号</label>
            <div class="layui-input-block">
                <input type="text" name="house_id" lay-verify="required" class="layui-input">
                <!--  <select name="houseId" lay-verify="required"  id="typeId" lay-search="">
                      <option value="">请选择房子</option>
                  </select>-->
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="updateSubmit">确认修改</button>
            </div>
        </div>
    </div>

<script src="../../../own/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        var id = parent.id;
        console.log(id)



        $.get('/user?method=selecUsertById',{id},function (res) {
            if(res.code==0){
                var dt = res.data;
                console.log(dt)
                //表单数据回显
                form.val("updateSubmit",dt)
                //重新渲染表单  避免表单控件无法显示
                form.render();
            }else {
                layer.msg(res.msg,{icon:2})
            }
        },'JSON')


        form.render();

        form.on('submit(updateSubmit)', function (data) {
            //获取表单中的数据信息
            let  user  = JSON.stringify(data.field);
            $.post('/user?method=updateUser',{user},function (res) {
                // 修改成功  关闭弹窗   重新加载数据表格
                if(res.code==200){
                    layer.msg('执行成功',{
                        iocn:6,
                        time:500
                    },function () {
                        //重载父窗口 关闭当前窗口
                        parent.window.location.reload();
                        var iframeIndex=parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    })
                }else {
                    // 修改失败
                    layer.msg(res.msg,{icon:2})
                }
            })
        });


    });
</script>
</body>
</html>